<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.jiadakeji.ppm.modules.sys.utils.*" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>房屋管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#btnImport").click(function(){
                $.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true},
                    bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
            });
        });
        function page(n,s){
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }
    </script>
</head>
<body>
<div id="importBox" class="hide">
    <form id="importForm" action="${ctx}/business/room/import" method="post" enctype="multipart/form-data"
          class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
        <input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
        <input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
        <a href="${ctx}/business/room/import/template">下载模板</a>
    </form>
</div>

<form:form id="searchForm" modelAttribute="room" action="${ctx}/business/room/addRoomList?replaceId=${replaceId}&replaceName=${replaceName}" method="post" class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <ul class="ul-form">
        <li><label>房屋名称：</label>
            <form:input path="name" htmlEscape="false" maxlength="255" class="input-medium"/>
        </li>
        <li><label>小区：</label>
            <form:select path="communityId" class="input-xlarge ">
                <form:option value="" label="请选择"/>
                <form:options items="${fns:getCommunityList()}" itemLabel="name" itemValue="id" htmlEscape="false"/>
            </form:select>
        </li>
        <li><label>楼栋：</label>
            <input type="hidden" name="hidden_buildingId" value="${room.buildingId}"/>
            <form:select path="buildingId" class="input-medium">
                <form:option value="">请选择</form:option>
            </form:select>
        </li>
        <li></li>
        <li><label>所有者名称：</label>
            <form:input path="houseHolderName" htmlEscape="false" maxlength="32" class="input-medium"/>
        </li>
        <li><label>使用者名称：</label>
            <form:input path="usingCustomerName" htmlEscape="false" maxlength="32" class="input-medium"/>
        </li>
        <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
            <input id="btnImport" class="btn btn-primary" type="button" value="导入"/>
        </li>

        <li class="clearfix"></li>
    </ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr><th>小区</th>
        <th>栋号</th>
        <th>房屋编号</th>
        <th>楼层</th>
        <th>房屋平方单价</th>
        <th>建筑面积</th>
        <th>使用面积</th>
        <th>是否使用</th>
        <th>所有者id</th>
        <th>使用者id</th>
        <shiro:hasPermission name="business:room:edit"><th>操作</th></shiro:hasPermission>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.list}" var="room">
        <tr>
            <td>
                    ${room.building.community.name}
            </td>
            <td>
                    ${room.building.name}
            </td>
            <td>
                    ${room.code}
            </td>
            <td>
                    ${room.storey}
            </td>

            <td>
                    ${room.roomTypePrice.name}
            </td>

            <td>
                    ${room.buildAreaSize}
            </td>
            <td>
                    ${room.usingAreaSize}
            </td>
            <td>
                    ${fns:getDictLabel(room.useFlag,"yes_no" ,"" )}
            </td>
            <td>
                    ${room.houseHolder.name}
            </td>
            <td>
                    ${room.usingCustomer.name}
            </td>
            <shiro:hasPermission name="business:room:edit"><td>
                <div>
                    <button type="button" class="btn btn-xs btn-info" name="chooseBtn"  roomName=" ${room.building.community.name}${room.building.name}${room.code}" roomId="${room.id}" >
                        <i class="ace-icon glyphicon glyphicon-book"></i>选择
                    </button>
                </div>
            </td></shiro:hasPermission>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>
<script src="${pageContext.request.contextPath}/static/common/list_relate.js"></script>
<script>
    jQuery(function($) {
        // 联动小区，楼栋
        var parameter = {
            url : "/a/business/building/getBuildingList",
            key : "communityId",
            // dataList:"schoolList",
            value : "id",
            text : "name",
            selectedVal : ""
        };
        $("select[name='communityId']").ajaxRelate(
            $("select[name='buildingId']"), parameter);
        $("select[name='buildingId']").val($("input[name='hidden_buildingId']").val()).trigger("change");


    });
</script>
<script src="${pageContext.request.contextPath}/static/common/pop_win.js"></script>
<script type="text/javascript">
    jQuery(function($) {
        $("button[name=chooseBtn]").on("click", function() {
            var roomId=$(this).attr("roomId");
            var roomName=$(this).attr("roomName");
            //console.log("userId",userId);
            //console.log("name",name);
            var form=parent.document.getElementById("inputForm");
            $(form).find("input[name='${replaceId}']").val(roomId);
             $(form).find("input[name='${replaceName}']").val(roomName);
            parent.document.getElementById("popWinClose").click();

        });
    });
</script>
</body>
</html>